#include<stdio.h>
#include <string.h>

void strDelete(char str[],int dBegin,int dLen) {
    int i=0,count=0;
    for(i=0; str[i]!='\0'; i++)
        count++;
    for(i=dBegin; i<count; i++) {
        if(i+dLen>=count) {
            str[i] = '\0';
            break;
        } else {
            str[i] = str[i+dLen];
        }
    }
}

void strDelete2(char *str, int dBegin, int dLen)
{
    if (!str) {
        return;
    }
    if (dLen <= 0) {
        return;
    }
    if (dBegin < 0) {
        dBegin = 0;
    }
    int slen = strlen(str);
    if (dBegin >= slen) {
        return;
    }
    if (dBegin + dLen > slen) {
        dLen = slen - dBegin;
    }
    while (1) {
        str[dBegin] = str[dBegin + dLen];
        if (str[dBegin] == '\0') {
            break;
        }
        dBegin++;
    }
}

int main()
{
    char str[] = "helloworld!";
    char str2[] = "helloworld!";
    strDelete(str,-50,2);
    strDelete2(str2,-50,2);
    printf("%s\n%s\n",str,str2);
    return 0;
}